package metuan_;

import java.util.Scanner;


/**
 * 1≤n,m≤ 50000,opi∈{0,1},
 * 当opi=0 时,1≤xi≤n,0≤yi≤10000;
 * 当opi=1 时，1≤xi≤yi≤n。
 * 保证至少有一次opi=1
 */
public class Main1 {
    private static int n,m;
    private static int[] op,x,y,a;
    private static long[] pres;
    private static boolean flag=false;

    private static long ans=0L;
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        //初始化数据
        extracted(scanner);
        for(int i=0;i<m;++i){
            //更新操作
            if(op[i]==0){
                a[x[i]]=y[i];
                //更新前缀和数组
                for(int j=x[i];j<=n;++j){
                    pres[j]=0L+pres[j-1]+a[j];
                }
//                print();
            }else{//查询操作

//                for(int j=x[i];j<=y[i];j++){
//                    ans+=(0L+a[j]);
//                }
                ans = 0L+pres[y[i]]-pres[x[i]-1];
                if(flag==false){
                    System.out.print(ans);
                    flag=true;
                }else{
                    System.out.print(" "+ans);
                }

            }
        }

    }

    private static void print(){
        for(int i=0;i<n+1;++i){
            System.out.print(" "+pres[i]+" ");
        }
        System.out.println();
    }
    private static void extracted(Scanner scanner) {
        n= scanner.nextInt();
        m= scanner.nextInt();
        op=new int[m];
        x=new int[m];
        y=new int[m];
        a=new int[n+1];//有n个收藏夹
        pres=new long[n+1];//前缀和数组
        for(int i=0;i<m;++i){
            op[i]= scanner.nextInt();
        }
        for(int i=0;i<m;++i){
            x[i]= scanner.nextInt();
        }
        for(int i=0;i<m;++i){
            y[i]= scanner.nextInt();
        }
    }
}
